package com.ruoyi.user.service;

import java.util.Date;
import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.user.domain.UserLevel;
import com.ruoyi.user.mapper.UserLevelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 会员级别Service业务层处理
 *
 * @author ruoyi
 * @date 2024-01-04
 */
@Service
public class UserLevelService {

    @Autowired
    private UserLevelMapper userLevelMapper;

    /**
     * 查询会员级别
     *
     * @param levelId 会员级别主键
     * @return 会员级别
     */
    public UserLevel selectUserLevelByLevelId(Long levelId) {
        return userLevelMapper.selectUserLevelByLevelId(levelId);
    }

    /**
     * 查询会员级别列表
     *
     * @param userLevel 会员级别
     * @return 会员级别
     */
    public List<UserLevel> selectUserLevelList(UserLevel userLevel) {
        return userLevelMapper.selectUserLevelList(userLevel);
    }

    /**
     * 新增会员级别
     *
     * @param userLevel 会员级别
     * @return 结果
     */
    public int insertUserLevel(UserLevel userLevel) {
        return userLevelMapper.insertUserLevel(userLevel);
    }

    /**
     * 修改会员级别
     *
     * @param userLevel 会员级别
     * @return 结果
     */
    public int updateUserLevel(UserLevel userLevel) {
        userLevel.setUpdateBy(SecurityUtils.getUsername());
        userLevel.setUpdateTime(new Date());
        return userLevelMapper.updateUserLevel(userLevel);
    }

    /**
     * 批量删除会员级别
     *
     * @param levelIds 需要删除的会员级别主键
     * @return 结果
     */
    public int deleteUserLevelByLevelIds(Long[] levelIds) {
        return userLevelMapper.deleteUserLevelByLevelIds(levelIds);
    }

    /**
     * 删除会员级别信息
     *
     * @param levelId 会员级别主键
     * @return 结果
     */
    public int deleteUserLevelByLevelId(Long levelId) {
        return userLevelMapper.deleteUserLevelByLevelId(levelId);
    }

    public List<UserLevel> selectUserLevelListByLevelValues(List<Integer> levelValues) {
        return userLevelMapper.selectUserLevelListByLevelValues(levelValues);
    }
}
